<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link th:href="@{/erp/assets/css/bootstrap.min.css}" rel="stylesheet"/>
    <link rel="stylesheet" th:href="@{/erp/css/style.css}"/>
    <link th:href="@{/erp/assets/css/codemirror.css}" rel="stylesheet">
    <link rel="stylesheet" th:href="@{/erp/assets/css/ace.min.css}"/>
    <link rel="stylesheet" th:href="@{/erp/font/css/font-awesome.min.css}"/>
    <link rel="stylesheet" th:href="@{/erp/assets/css/font-awesome.min.css}"/>
    <!--[if lte IE 8]>
    <link rel="stylesheet" th:href="@{/erp/assets/css/ace-ie.min.css}"/>
    <![endif]-->
    <script th:src="@{/erp/js/jquery-1.9.1.min.js}"></script>
    <script th:src="@{/erp/assets/js/bootstrap.min.js}"></script>
    <script type="text/javascript" th:src="@{/erp/Widget/Validform/5.3.2/Validform.min.js}"></script>
    <script th:src="@{/erp/assets/js/typeahead-bs2.min.js}"></script>
    <script th:src="@{/erp/assets/js/jquery.dataTables.min.js}"></script>
    <script th:src="@{/erp/assets/js/jquery.dataTables.bootstrap.js}"></script>
    <script th:src="@{/erp/assets/layer/layer.js}" type="text/javascript"></script>
    <script th:src="@{/erp/js/lrtk.js}" type="text/javascript"></script>
    <script th:src="@{/erp/assets/layer/layer.js}" type="text/javascript"></script>
    <script th:src="@{/erp/assets/laydate/laydate.js}" type="text/javascript"></script>
    <title>物流结算</title>
</head>
<body>
<div class="page-content clearfix">
    <div class="administrator">
        <div class="d_Confirm_Order_style">
            <div class="search_style">
                <ul class="search_content clearfix">

                    <form>


                        <li>
                            <label class="l_f">运货单号：</label>
                            <input name="freightId" type="tel" class="text_add" placeholder="" style=" width:150px"/>
                        </li>

                        <li style="width:90px;">
                            <button type="button" id="selectbyid" class="btn_search"><i class="fa fa-search"></i>查询</button>
                        </li>
                    </form>
                </ul>
            </div>
            <!--操作-->
            <div class="border clearfix" id="jiesuanxinxi">

            </div>
            <div class="table_menu_list" id="testIframe">
                <table class="table table-striped table-bordered table-hover" id="sample-table1">
                    <thead>
                    <tr>
                        <th style='display:none' width="100px">ID</th>
                        <th width="25px">序号</th>
                        <th width="120px">运货单号</th>
                        <th width="100px">货物类别</th>
                        <th width="100px">出发地</th>
                        <th width="100px">目的地</th>
                        <th width="100px">运送距离(km)</th>
                        <th width="100px">货物重量(T)</th>
                        <th width="100px">货物体积(m³)</th>
                        <th style='display:none' width="100px">商品数量</th>
                        <th style='display:none' width="100px">订单ID</th>
                        <th style='display:none' width="100px">物流公司名字</th>
                        <th style='display:none' width="100px">车辆名字</th>
                        <th style='display:none' width="100px">结算金额</th>
                        <th width="100px">结算状态</th>
                        <th width="100px">操作</th>
                    </tr>
                    </thead>
                    <tbody>

                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
<!--物流结算-->
<div id="add_administrator_style" class="add_menber" style="display:none">

    <div class="Operate_cont clearfix">
        <label class="form-label"><span class="c-red">*</span>物流公司：</label>
        <div class="formControls ">
            <input  type="text" class="input-text" value="000020161221" readonly="readonly" placeholder="" id="logistic" name="物流公司">
        </div>
    </div>
    <div class="Operate_cont clearfix">
        <label class="form-label"><span class="c-red">*</span>运送车辆：</label>
        <div class="formControls ">
            <input  type="text" class="input-text" value="000020161221" readonly="readonly" placeholder="" id="logisticway" name="运送方式">
        </div>
    </div>
    <div class="Operate_cont clearfix">
        <label class="form-label"><span class="c-red">*</span>运货单号：</label>
        <div class="formControls ">
            <input  type="text" class="input-text" value="000020161221" readonly="readonly" placeholder="" id="shippingNum" name="运货单号">
        </div>
    </div>
    <div class="Operate_cont clearfix">
        <label class="form-label"><span class="c-red">*</span>货物种类：</label>
        <div class="formControls ">
            <input  type="text" class="input-text" value="电池" readonly="readonly" placeholder="" id="shoppingType" name="货物种类">
        </div>
    </div>
    <div class="Operate_cont clearfix">
        <label class="form-label"><span class="c-red">*</span>订单编号：</label>
        <div class="formControls ">
            <input  type="text" class="input-text" value="0020161223456" readonly="readonly" placeholder="" id="orderNum" name="订单编号">
        </div>
    </div>
    <div class="Operate_cont clearfix">
        <label class="form-label"><span class="c-red">*</span>数量：</label>
        <div class="formControls ">
            <input  type="text" class="input-text" value="200" readonly="readonly" placeholder="" id="settlementNumber" name="数量">&nbsp;个
        </div>
    </div>
    <div class="Operate_cont clearfix">
        <label class="form-label"><span class="c-red">*</span>出发地：</label>
        <div class="formControls ">
            <input  type="text" class="input-text" value="浙江杭州" readonly="readonly" placeholder="" id="startPlace" name="出发地">
        </div>
    </div>
    <div class="Operate_cont clearfix">
        <label class="form-label"><span class="c-red">*</span>目的地：</label>
        <div class="formControls ">
            <input  type="text" class="input-text" value="湖北武汉" readonly="readonly" placeholder="" id="endPlace" name="湖北武汉">
        </div>
    </div>
    <div class="Operate_cont clearfix">
        <label class="form-label"><span class="c-red">*</span>货物重量：</label>
        <div class="formControls ">
            <input  type="text" class="input-text" value="50" readonly="readonly" placeholder="" id="quality" name="货物重量">&nbsp;T
        </div>
    </div>
    <div class="Operate_cont clearfix">
        <label class="form-label"><span class="c-red">*</span>货物体积：</label>
        <div class="formControls ">
            <input  type="text" class="input-text" value="300" readonly="readonly" placeholder="" id="pValue" name="货物体积">&nbsp;m³
        </div>
    </div>
    <div class="Operate_cont clearfix">
        <label class="form-label"><span class="c-red">*</span>结算金额：</label>
        <div class="formControls ">
            <input  type="text" class="input-text"  placeholder="" id="settlementMoney" name="结算金额">&nbsp;元
        </div>
    </div>



</div>

</body>
</html>
<script type="text/javascript">
    jQuery(function ($) {

        $.ajax({
            url: '[[@{/settlement/findsettlementStatus}]]',
            success: function (data) {
                console.log(data);
                if(data.rs){
                    var d=data.data;
                    $('#jiesuanxinxi:last').append("<span class='l_f'> 已结算" + d[0] +"条,未结算"+d[1]+"条</span>");
                }else{
                    layer.msg(data.msg,{icon:2,time:2000})
                }


            }

        })


        var oTable1 = $('#sample-table1').dataTable({
            searching: false,
            serverSide: true,
            ajax: {
                url: '/settlement/findAll',
                type: 'post',
                data: function (d) {
                    var data = $('form').serialize();
                    var searchParame = {
                        start: d.start,
                        length: d.length,
                    };
                    data = data + '&' + $.param(searchParame);
                    return data;
                }
            },


            columns: [
                {"data": "settlementId", "className": "hidden"},
                {
                    "data": "settlementId", "createdCell": function (td, cellData, rowData, row, col) {
                        $(td).empty().append(row + 1)
                    }
                },
                {"data": "shippingNum"},
                {"data": "shoppingType"},
                {"data": "startPlace"},
                {"data": "endPlace"},
                {"data": "distance"},
                {"data": "quality"},
                {"data": "pvalue"},
                {"data": "settlementNumber", "className": "hidden"},
                {"data": "orderNum", "className": "hidden"},
                {"data": "logisticname", "className": "hidden"},
                {"data": "logisticway", "className": "hidden"},
                {"data": "settlementMoney", "className": "hidden"},
                {
                    "data": "settlementStatus", "createdCell": function (td, cellData, rowData, row, col) {
                        if (cellData == "1") {
                            $(td).empty().append('<span class="label label-success radius">已结算</span>')
                        } else if (cellData == "-1") {
                            $(td).empty().append('<span style="color:#FF0000" class="label label-defaunt radius">未结算</span>')
                        }
                    }
                },
                {

                    "data": "settlementStatus", "createdCell": function (td, cellData, rowData, row, col) {
                        if(rowData.settlementStatus=="1") {
                            $(td).empty().append(' <a title="结算"  class="btn btn-xs " ><i class="fa  bigger-120">结算</i></a> \n')
                        }else{
                        $(td).empty().append(' <a title="结算" href="javascript:;"  onclick="adddriver(this,\'1\')"  class="btn btn-xs btn-info" ><i class="fa  bigger-120">结算</i></a> \n')
                        }
                    }
                },

            ]
        })

        /*搜索*/
        $('#selectbyid').click(function () {
            oTable1.fnUpdate();
        })


       





    });

</script>
<script type="text/javascript">













    function adddriver(e) {
        var id = $(e).parent().parent().children("td:eq(0)").text();
        document.getElementById('shippingNum').value = $(e).parent().parent().children("td:eq(2)").text();
        document.getElementById('shoppingType').value = $(e).parent().parent().children("td:eq(3)").text();
        document.getElementById('startPlace').value = $(e).parent().parent().children("td:eq(4)").text();
        document.getElementById('endPlace').value = $(e).parent().parent().children("td:eq(5)").text();
        document.getElementById('quality').value = $(e).parent().parent().children("td:eq(7)").text();
        document.getElementById('pValue').value = $(e).parent().parent().children("td:eq(8)").text();
        document.getElementById('settlementNumber').value = $(e).parent().parent().children("td:eq(9)").text();
        document.getElementById('orderNum').value = $(e).parent().parent().children("td:eq(10)").text();
        document.getElementById('logistic').value = $(e).parent().parent().children("td:eq(11)").text();
        document.getElementById('logisticway').value = $(e).parent().parent().children("td:eq(12)").text();
        document.getElementById('settlementMoney').value = $(e).parent().parent().children("td:eq(13)").text();
        layer.open({
            type: 1,
            title: '结算金额',
            area: ['530px', '660px'],
            shadeClose: false,
            content: $('#add_administrator_style'),
            btn: ['结算金额'],
            yes: function (index, layero) {
                var num = 0;
                var str = "";
                console .log("111")
                console.log($('#settlementMoney').val())
                $("#add_administrator_style input[type$='text']").each(function (n) {
                    if ($(this).val() == "") {
                        layer.alert(str += "" + $(this).attr("name") + "不能为空！\r\n", {
                            title: '提示框',
                            icon: 0,
                        });
                        num++;
                        return false;
                    }
                });
                if (num > 0) {
                    return false;
                } else {

                    $.ajax({
                        data: {
                            "id": id
                        },
                        type: 'post',
                        dataType: 'josn',
                        url: '/settlement/updatesettlement',
                        success: function (data) {
                            alert(data);
                            if(!data.rs){
                                layer.msg(data.msg,{icon:2,time:2000})
                            }
                        }
                    });

                    parent.layer.alert('结算成功！', {
                        title: '提示框',
                        icon: 1,
                    });
                    layer.close(index);
                    window.parent.document.getElementById('iframe').contentWindow.location.reload(true);
                }
            }
        });
    }


</script>